<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>

<body>
    <button id="find">查找用户（get请求无参数）</button>
    <button id="add">新增用户（post请求带参数）</button>
    <button id="del">删除用户（get请求带参数）</button>

    <script>
        let findBtn = document.getElementById("find");
        let addBtn = document.getElementById("add");
        let delBtn = document.getElementById("del");

        delBtn.onclick = function () {
            axios({
                url: "http://localhost:3000/user/delete",
                method: "get",
                params: {
                    id: 2
                }
            })
            .then(res => {
                console.log(res);
            })
        }

        addBtn.onclick = function () {
            axios({
                url:"http://localhost:3000/user/add",
                method:"post",
                data:{
                    id:3,
                    name:"Tom",
                    age:27
                }
            }).then(res => {
                console.log(res);
            })
        }

        findBtn.onclick = function () {
            axios({
                url: "http://localhost:3000/user/find",
            })
                .then(res => {
                    console.log(res);
                })
        }
    </script>
</body>

</html>